#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int a[2000];
	for (int i = 0; i < m + n; i++)
	{
		scanf("%d", &a[i]);
	}
	int temp = 0;
	for (int i = 0; i < m + n; i++)
	{
		for (int j = i + 1; j < m + n; j++)
		{
			if (a[j] < a[i])
			{
				temp = a[i];
				a[i] = a[j];
				a[j] = temp;
			}
		}
	}
	for (int i = 0; i < m + n; i++)
	{
		printf("%d ", a[i]);
	}
	return 0;
}